package com.zp.kidshop.common.exception;

import java.io.PrintStream;
import java.io.PrintWriter;
/**
 * 
 * @Title: BaseNeException.java
 * @Package com.minghang.common.exception.aop 
 * @Description: 异常类--继承Exception类
 * @author 张鹏  
 * @date 2017年2月16日 下午2:57:38 
 * @version V1.0
 */
public class BaseNeException extends Exception {
	private static final long serialVersionUID = 1480418986851739996L;
	private String errCode;

	public BaseNeException(String msg) {
		super(msg);
	}
	
	public BaseNeException(Throwable ex) {
		super(ex);
	}

	public BaseNeException(String msg, Throwable ex) {
		super(msg,ex);
	}

	public BaseNeException(String errCode,String msg, Throwable ex) {
		super(msg,ex);
		this.errCode = errCode;
	}

	public Throwable getCause() {
//		return (this.cause == null ? this : this.cause);
		return super.getCause();
	}

	public String getMessage() {
//		String message = super.getMessage();
//		Throwable cause = getCause();
//		if (cause != null) {
//			message = message + "nested Exception is " + cause.getLocalizedMessage();
//		}
		return super.getMessage();
	}

	public void printStackTrace(PrintStream ps) {
		if (getCause() == null) {
			super.printStackTrace(ps);
		} else {
			ps.println(this);
			getCause().printStackTrace(ps);
		}
	}

	public void printStackTrace(PrintWriter pw) {
		if (getCause() == null) {
			super.printStackTrace(pw);
		} else {
			pw.println(this);
			getCause().printStackTrace(pw);
		}
	}

	public void printStackTrace() {
		printStackTrace(System.err);
	}
	
	public String getErrCode(){
		return this.errCode;
	}
}
